
#include <sys/sem.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <stdlib.h>
#include <iostream>
using namespace std;

int main()
{
	key_t key;
	char s[] = "main.cpp";
	struct sembuf mybuf;
	int semid;
	key = ftok(s,0);
	if(key < 0) {
		cout << "error !" << endl;
		exit(-1);
	}
	semid = semget(key, 1, IPC_CREAT|0644);
	if(semid < 0) exit(-1);
	mybuf.sem_num = 0;
	mybuf.sem_flg = 0;
	mybuf.sem_op = -4;
	semop(semid, &mybuf, 1);
	cout << "main continues" << endl;
	return 0;

}
